#ifndef DATABASE_FIELD_H
#define DATABASE_FIELD_H
/*
	Field attributes
		Type					INT, MEDIUMINT UNSIGNED, VARCHAR, etc.
		Max_len					VARCHAR(255) (=255), INT (=4), etc.
		Current_len
		Is_variable_len			bool
		Default val
		Default_val_is_null		bool
		Val
		Val_is_null				bool

*/

#include <cstddef>
#include <cstring>

#include "columnspec.h"


namespace Database
{

using std::size_t;
using std::string;

class Field
{
public:
	Field(const ColumnSpec& colspec, const bool isNull, const void *data, const size_t dataLen);
	virtual ~Field();

	const string asString() const;
	const size_t byteLength() const;
	const void *data() const;
	const bool isNull() const;
	const bool isNullable() const;
	const size_t maxByteLength() const;

private:
	union Data
	{
		unsigned int dUInt;
		int dInt;
		char * dChar;
	};

	const ColumnSpec colspec_;
	size_t byteLen_;
	bool isNull_;

	union Data data_;
};

}	// namespace Database

#endif

